﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SPPD.model;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Linq;

namespace SPPD.controller
{
    class controller_divisi
    {
        crud <divisi> nhi;
        List <divisi> div;
        public controller_divisi()
        {
            nhi = new crud <divisi> ();
            div = new List <divisi>();
        }
        public void insert(divisi div)
        {
            nhi.insert(div);
        }
        public List<divisi> load()
        {
            var factory = nhi.load();
            using (var session = factory.OpenSession())
            {
                var categories = session.Query<divisi>()
                       .ToList();
                return categories;
            }     
        }
        public string autogenerate()
        {  
            div = load();
            return "DI" + (div.Count + 1);
        }
    }
}
